package controller.res;

import model.MResource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import common.interf.IErrorHandle;

import service.interf.IResource;

@Controller
@RequestMapping("/res")
public class ResourceFindController {
	@Autowired
	private IResource res;
	@Autowired
	private IErrorHandle errorHandle;
	
	@RequestMapping("/find_all_resource.htm")
	@ResponseBody
	public String findAll() {
		String s = "";
		try {
			s = res.findAllResources(false, 0, 0);
		} catch (Exception e) {
			errorHandle.handleErr(e);
		}
		return s;
	}
	
	@RequestMapping("/find_resourceByType.htm")
	@ResponseBody
	public String findByType(MResource model) {
		String s = "";
		try {
			s = res.findResourcesByType(model.getResourceTypeId(), false, 0, 0);
		} catch (Exception e) {
			errorHandle.handleErr(e);
		}
		return s;
	}
	
}
